<template>
  <div>
    <el-dialog
      title="文章分类添加"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-form ref="ruleForm" :model="ruleForm">

        <el-form-item label="分类名称" prop="CategoryName">
          <el-input v-model="ruleForm.CategoryName" />
        </el-form-item>
      </el-form>
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="addOrUpdate">确 定</el-button>

    </el-dialog>

  </div>

</template>

<script>
// doc: https://panjiachen.github.io/vue-element-admin-site/feature/component/svg-icon.html#usage
import * as category from '@/api/category'
export default {
  name: 'AddCategory',

  data() {
    return {
      dialogVisible: this.visible,
      ruleForm: { CategoryName: '' }
    }
  },
  computed: {

  },
  created() {
    this.dialogVisible = this.visible
  },
  methods: {
    load() {
      category.loadfirst().then(res => {
        this.firstLevelCategories = res
    })
    },
    addOrUpdate() {
     category.addorupdate(this.ruleForm).then(res => {
     }).catch(res => {
     })
    },
    handleClose() {
        this.close()
     },
     close() {
      this.dialogVisible = false
     }
  }
}
</script>

<style scoped>
</style>
